<?php
	$items = $self->getCollection();
?>
<div class="content-header row-fluid">
	<h3 class="pull-left"><?php echo $self->getTitle() ?></h3>
	<div class="actions pull-right">
		<a href="<?php echo $self->getNewUrl() ?>" class="btn">Add</a>
	</div>
</div>

<div class="toolbar-top">
<?php $self->renderChild('toolbar') ?>
</div>

<form method="GET">
<input type="submit" class="hide" vlue="search" />
<table class="table table-bordered table-hover">
	<colgroup>
		<col width="50"/>
		<col/>
		<col class="hidden-phone hidden-tablet"/>
		<col width="120" class="hidden-phone"/>
		<col width="120" class="hidden-phone"/>
	</colgroup>

	<thead>
		<tr>
			<th><a href="<?php echo $self->getOrderUrl('id') ?>">
				<i class="<?php echo $self->getClass('id') ?>"></i>
				ID
			</a></th>
			<th><a href="<?php echo $self->getOrderUrl('title') ?>">
				<i class="<?php echo $self->getClass('title') ?>"></i>
				Title
			</a></th>
			<th class="hidden-phone hidden-tablet"><a href="<?php echo $self->getOrderUrl('description') ?>">
				<i class="<?php echo $self->getClass('description') ?>"></i>
				Description
			</a></th>
			<th class="hidden-phone"><a href="<?php echo $self->getOrderUrl('created_time') ?>">
				<i class="<?php echo $self->getClass('created_time') ?>"></i>
				Created At
			</a></th>
			<th class="hidden-phone"><a href="<?php echo $self->getOrderUrl('update_time') ?>">
				<i class="<?php echo $self->getClass('update_time') ?>"></i>
				Update At
			</a></th>
		</tr>
		<tr>
			<th>
				<input type="text" name="id" value="<?php echo App::get('id') ?>" class="span24" />
			</th>
			<th>
				<input type="text" name="title" value="<?php echo App::get('title') ?>" class="span24" />
			</th>
			<th class="hidden-phone hidden-tablet">
				<input type="text" name="description" value="<?php echo App::get('description') ?>" class="span24" />
			</th>
			<th class="hidden-phone">
				<input type="text" name="created_time" value="<?php echo App::get('created_time') ?>" class="span24" />
			</th>
			<th class="hidden-phone">
				<input type="text" name="update_time" value="<?php echo App::get('update_time') ?>" class="span24" />
			</th>
		</tr>
	</thead>
	
	<tbody>
		<?php foreach($items as $item): ?>
		<tr title="<?php echo $self->getRowUrl($item->getId()) ?>">
			<td><?php echo $item->getId() ?></td>
			<td><?php echo truncate($item->getTitle()) ?></td>
			<td class="hidden-phone hidden-tablet"><?php echo truncate($item->getDescription(), 80) ?></td>
			<td class="hidden-phone"><?php echo date('d-m-Y', strtotime( $item->getCreatedTime() )) ?></td>
			<td class="hidden-phone"><?php echo date('d-m-Y', strtotime( $item->getUpdateTime() )) ?></td>
		</tr>
		<?php endforeach ?>
	</tbody>
</table>
</form>

<div class="toolbar-bottom">
<?php $self->renderChild('toolbar') ?>
</div>

<script type="text/javascript">
//<![CDATA[
$('.table tbody tr').click(function () {
	setLocation(this.title);
});
//]]>
</script>
